package com.base.cn.platform.os.controller.op.activity;

import com.base.cn.platform.os.common.utils.result.ResultUtil;
import com.base.cn.platform.os.controller.cmmon.ApiBaseController;
import com.base.cn.platform.os.service.manage.op.activity.OpActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 活动接口
 *
 * @author s.li
 * @date 2019/05/21
 */
@RestController
@RequestMapping("/api/op")
public class ApiActivityController extends ApiBaseController {
    @Autowired
    private OpActivityService opActivityService;

    /**
     * 查询课程详情可以显示的活动
     * @param price 课程价格
     * @return Map<String,Object>
     */
    @RequestMapping("/getCourseInfoActivity")
    @ResponseBody
    public Map<String,Object> getCourseInfoActivity(@RequestParam(value = "price",required = false,defaultValue = "0") Double price){
        Map<String,String> map = new HashMap<>();
        map.put("price",String.valueOf(price));

        List<Map<String,String>> params = new ArrayList<>();
        params.add(map);

        List<Map<String,Object>> activityList = opActivityService.findOrderAvailableActivityList(params,false);
        return ResultUtil.SUCCESS(activityList);
    }
}
